package learning.algorithm.tree.bst;

import java.util.Comparator;
import java.util.TreeSet;

public class TestMain {
    static class Person {
        private int age;
        private String name;

        public Person(int age, String name) {
            this.age = age;
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

    static class Car implements Comparable<Car> {
        private int price;

        public Car(int price) {
            this.price = price;
        }

        public int getPrice() {
            return price;
        }

        public void setPrice(int price) {
            this.price = price;
        }

        @Override
        public int compareTo(Car o) {
            return price - o.getPrice();
        }
    }

    public static void main(String[] args) {
        BinarySearchTree<Person> binarySearchTree = new BinarySearchTree<>(new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o1.getAge() - o2.getAge();
            }
        });
        binarySearchTree.add(new Person(7, "张三"));
        binarySearchTree.add(new Person(3, "李四"));
        binarySearchTree.add(new Person(8, "王五"));
        binarySearchTree.add(new Person(6, "张就"));
        binarySearchTree.add(new Person(9, "忙完"));

        TreeSet<Car> treeSet = new TreeSet<>();

        BinarySearchTree<Car> carBinarySearchTree = new BinarySearchTree<>();
        carBinarySearchTree.add(new Car(7));
        carBinarySearchTree.add(new Car(3));
        carBinarySearchTree.add(new Car(8));
        carBinarySearchTree.add(new Car(6));
        carBinarySearchTree.add(new Car(9));
    }
}

